package cn.rentaotao.spring.config;

import cn.rentaotao.spring.filter.MyFilter;
import org.springframework.web.WebApplicationInitializer;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

/**
 * @author rtt
 * @date 2022/5/26 09:57
 */
public class CustomerWebAppInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {

        // 添加 Filter
        FilterRegistration.Dynamic registration = servletContext.addFilter("myFilter", MyFilter.class);

        registration.addMappingForServletNames(null , false, "/spittle");

        // 添加 Listener
        servletContext.addListener(new ContextListener());
    }

}
